

package usercodedeployment;

import com.hazelcast.map.EntryProcessor;

import java.io.Serial;
import java.util.Map;

public class EntryProcessorWithAnonymousAndInner implements EntryProcessor<Integer, Integer, Integer> {

    @Serial
    private static final long serialVersionUID = 8936595533044945435L;

    @Override
    public Integer process(final Map.Entry<Integer, Integer> entry) {
        Integer origValue = entry.getValue();
        final Integer newValue = origValue + 1;

        final Test test = new Test(entry);
        Runnable runnable = () -> test.set(newValue);
        runnable.run();

        return newValue;
    }

    public class Test {
        private final Map.Entry<Integer, Integer> entry;

        Test(Map.Entry<Integer, Integer> entry) {
            this.entry = entry;
        }

        void set(Integer newValue) {
            entry.setValue(newValue);
        }
    }
}
